package concurrency;

import java.io.IOException;

class UnresponsiveUI {
    private volatile double mData = 1;

    public UnresponsiveUI() {
        while(mData > 0) {
            mData = mData + (Math.PI + Math.E) / mData;
        }

        try {
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

/**
 * 创建有响应的用户界面
 *
 * 2018年 09月 25日 星期二
 * @author fireway
 */
public class ResponsiveUI extends Thread {
    private static volatile double sData  = 1;

    public ResponsiveUI() {
        setDaemon(true);
        start();
    }

    @Override
    public void run() {
        while(true) {
            sData = sData + (Math.PI + Math.E) / sData;
        }
    }

    public static void main(String[] args) {
        //! new UnresponsiveUI();
        new ResponsiveUI();
        try {
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(sData);
    }
}
